﻿#ifndef DLGMENU_H
#define DLGMENU_H

//(*Headers(DlgMenu)
#include <wx/dialog.h>
//*)
#include <wx/sizer.h>
#include <wx/textctrl.h>
#include <wx/button.h>
#include <wx/choice.h>
#include <wx/combobox.h>
#include <wx/listctrl.h>
#include <wx/stattext.h>
#include <wx/log.h>
#include <wx/statbmp.h>
#include <wx/buffer.h>
#include <opencv2/core/core.hpp>
#include <vector>
#include <utility>
#include "PublicData.h"
using std::vector;
using std::pair;

class CDlgMenu: public wxDialog
{
public:

    CDlgMenu(wxWindow* parent,wxWindowID id=wxID_ANY,const wxPoint& pos=wxDefaultPosition,const wxSize& size=wxDefaultSize);
    virtual ~CDlgMenu();

    //(*Declarations(DlgMenu)
    //*)

    //(*Identifiers(DlgMenu)
    //*)

private:
//控件ID
    static const long IDC_BTN_ADD_MOD;
    static const long IDC_BTN_EXIT;
    static const long IDC_BTN_SEARCH;
    static const long IDC_BTN_DEL;
    static const long IDC_BTN_PIC;
    static const long IDC_COMBO_SEARCH;
    static const long IDC_COMBO_TYPE;
    static const long IDC_EDIT_SEARCH;
    static const long IDC_RICHEDIT_MATERIAL;
    static const long IDC_RICHEDIT_REMARK;
    static const long IDC_EDIT_NAME;
    static const long IDC_PIC;
    static const long IDC_LIST;
    //控件变量
    wxBoxSizer *topSizer_;
    wxButton *btn_Add_Mod_;
    wxButton *btn_Exit_;
    wxButton *btn_Search_;
    wxButton *btn_Del_;
    wxButton *btn_pic_;
    wxChoice *combo_search_;
    wxChoice *combo_type_;
    wxTextCtrl *text_search_;
    wxTextCtrl *text_name_;
    wxTextCtrl *text_material_;
    wxTextCtrl *text_remark_;
    wxStaticBitmap *text_pic_;
    wxListCtrl *list_;

    //控件事件
    void OnBnClickedBtnSearch(wxCommandEvent& event);
    void OnBnClickedBtnDel(wxCommandEvent& event);
    void OnBnClickedBtnExit(wxCommandEvent& event);
    void OnBnClickedBtnAddMod(wxCommandEvent& event);
    void OnBnClickedBtnPic(wxCommandEvent& event);
    void OnNMClickList(wxListEvent& event);
    void OnNMDblclkList(wxListEvent& event);
    void OnPaint(wxPaintEvent& event);

    //成员变量
    int m_addormod_;//0表示没执行添加或更新操作，1为表示执行添加操作，2表示执行更新操作
    wxString m_keyvalue_;//数据表中主键值
    vector<pair<wxString,int> >m_typenameandid_;
    cv::Mat m_img_;//图像显示用
    map<wxString,wxMemoryBuffer>m_picdata_map_;//菜名与图像数据的对应map

    //自定义函数
    void CreateCtrlAndEvent();//创建控件
    void EnableAllCtrl(bool isEnable);
    void InitComboBoxAndListCtrl();
    static const wxString TABLENAME;
    DECLARE_EVENT_TABLE()
};

#endif
